<extend name="Base:base" />
<block name="base_main">
	<link rel="stylesheet" href="__PUBLIC__/seller/css/validform.css" />
	<script src="__PUBLIC__/seller/js/Validform_v5.3.2.js"></script>
	<style>
		body{ background:#fff }
	</style>
	<div class="tpl-block ">
		<div class="am-g tpl-amazeui-form">
			<div class="am-u-sm-12 am-u-md-9">
				<form class="am-form am-form-horizontal" request_type="parent" action="" name="myfromSubmit" method="post">
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">手机号</label>
						<div class="am-u-sm-9">
							<?php echo preg_replace('/^([0-9]{3})([0-9]{4})([0-9]{4})$/','$1****$3' , $login_info['contact_tel']); ?>	
						</div>
					</div>

					<div class="am-form-group">
						<label for="user-email" class="am-u-sm-3 am-form-label">验证码</label>
						<div class="am-u-sm-3 float_left">
							<input type="text" datatype="*" value="" name="code" id="code" placeholder="验证码">
						</div>
						<div class="am-u-sm-4 float_left">
							<button class="am-btn am-btn-default" type="button" data-type="orgin" id="get_checked">
									获得验证码
							</button>
						</div>
					</div>
					<div class="am-form-group" id="show_app_key" style="display:none">
						<label for="user-name" class="am-u-sm-3 am-form-label">商家APP_KEY</label>
						<div class="am-u-sm-9">
							
						</div>
					</div>
					<div class="am-form-group">
						<div class="am-u-sm-9 am-u-sm-push-3">
							<button type="button" class="am-btn am-btn-primary" id="get_app_key_data">获取商家APP_KEY</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script>
		obj_position = 'parent';
		call_submit_back_flag = true;
		function call_submit_back_func() {
			parent.localhost.reload();
		}
		$('button#get_checked').click(function(){
				var _self = $(this);
				var url = '{:U('Accunt/appKeyCheck')}';
				$.get( url , function( data ){
					if( data.status == 1 ) {
							success( '短信验证码发送成功' );
							var times = 30;
							_self.attr('disabled' , true);
							var timeIndex = setInterval(function(){
									if( times <= 0 ) {
										_self.text( '重新发送' ).attr('disabled' , false);
										clearInterval( timeIndex );
									} else {
										_self.text( times + ' s');
										times--;
									}
							}, 1000);
					} else {
							error( data.msg );	
					}
				} , 'json');
		});
		
		$('#get_app_key_data').click(function(){
				var code = $('#code').val();
				if( code == '' ) {
					error( '验证码不能为空' );
					return false;
				}
				$.post('{:U('Accunt/appKeyShow')}',{code : code} , function(data){
					if( data.status == 1 ) {
						success('获取成功');
						$('#show_app_key').show().find('.am-u-sm-9').text(data.key);
					} else {
						error( data.msg );
					}
				} , 'json');
		});
	</script>
</block>